package ui;

import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

public class TimeView extends Label {

	private SimpleDateFormat simpleDateFormat;
	private String totalView;
	private String currentView;
	private Date totalTime;
	private Date currentTime;
	public TimeView(Composite parent, int style) {
		super(parent, style);
		simpleDateFormat = new SimpleDateFormat("mm:ss");
		initail("0");
	}
	@Override
	protected void checkSubclass() {}
	
	public void initail(String totalTime) {
		this.totalTime = new Date(Long.parseLong(totalTime));
		currentTime = new Date(0);
		totalView = simpleDateFormat.format(this.totalTime);
		currentView = "00:00";
		setText(currentView + '/' + totalView); 
	}
	
	public void setProgress(double progress) {
		currentTime = new Date((long) (totalTime.getTime() * progress));
		currentView = simpleDateFormat.format(currentTime); 
		setText(currentView + '/' + totalView);
	}
}
